package com.example.mvvmdemo.base

import androidx.multidex.MultiDex
import com.blankj.utilcode.util.LogUtils
import com.example.mvvmdemo.BuildConfig
import com.example.mvvmdemo.data.db.IDatabase
import com.squareup.leakcanary.LeakCanary
import com.yangk.mvvm.app.GlobalConfig
import com.yangk.mvvm.app.MVVMY
import com.yangk.mvvm.base.BaseApplication
import com.yangk.mvvm.base.ViewModelFactory

class App : BaseApplication() {

    override fun onCreate() {
        super.onCreate()
        IDatabase.getInstanse()
        init()
    }

    private fun init() {
        MultiDex.install(this)
        // 在OnCreate 中可以传入 自定义的 GlobalConfig
        MVVMY.install(object : GlobalConfig {
            override fun viewModelFactory() = ViewModelFactory.getInstance()
        })
        //内存泄漏检测
        if (!LeakCanary.isInAnalyzerProcess(this)) {
            LeakCanary.install(this)
        }

        LogUtils.getConfig().run {
            isLogSwitch = BuildConfig.DEBUG
            setSingleTagSwitch(true)

        }

    }
}